// pages/recruit/personal/resume/addselfappraisal/addselfappraisal.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    textlimit: 0,
    comment: "",
    state: "new",//默认新建，进来时带有状态时则变为修改。
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this;
    const eventChannel = this.getOpenerEventChannel()
    eventChannel.on('crossdata', function (res) {
      console.log(res)
      that.setData({
        textlimit: res.data.length,
        comment: res.data,
        state: "edit"
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  textarea: function(e){
    const that = this;
    that.setData({
      comment: e.detail.value,
      textlimit: e.detail.value.length
    })
  },
  back: function () {
    wx.navigateBack({})
  },
  commit: function () {
    const that = this;
    var box = that.data.comment;
    var title;
    if (box == "") {
      title = "请填写自我评价"
    }  else {
        // box.resumeId = getApp().globalData.resumeId;
        getApp().globalData.get("/api/resume/comment", {
          id: getApp().globalData.resumeId,
          comment:box
        }).then(res => {
          wx.navigateBack();
        })
    }
    wx.showToast({
      title: title,
      icon: "none",
      duration: 1000
    })
  }
})